<?php
header("content-type:text/html;charset=utf-8");

require_once('s.php');

abstract class mysql implements sql{


}



class yousql extends mysql{
	private $localhost = "localhost";
	private $name = "root";
	private $code = "root";
	private $database = "pro";
	private $con;
	private $sql;
	private $t_name;


private function connect(){
	$this->con = mysql_connect($this->localhost,$this->name,$this->code);
	mysql_select_db($this->database,$this->con);
	mysql_query("set names utf8");
}


private function __destruct(){
    mysql_close($this->con);
}

private function query($sql){
    return mysql_query($this->sql);
}

public function getAll($sql){
     $this->connect();
     $result = $this->query($sql);
     while($tmp=mysql_fetch_array($result,MYSQL_ASSOC)){
	 $list[] = $tmp;
	 }
	 return $list;
}

public function select($param,$obj_page=''){
	$this->connect();
    $keys = array_keys($param);
    $values = array_values($param);
    foreach ($keys as $one) {
    	$col = '`'.$one.'`,';
    }
    $col = substr(0,strlen($col)-1);

    foreach ($values as $two) {
    	$val = '`'.$two.'`,';
    }
    $val = substr(0,strlen($val)-1);

    $sql = 'select  $col from $val';
    $result = $this->query($sql);
    while($tmp=mysql_fetch_array($result,MYSQL_ASSOC)){
	$list[] = $tmp;
	}
	return $list;
}

public function insert($t_name,$insert_array=array()){
	$this->connect();
    $keys = array_keys($insert_array);
    $values = array_values($insert_array);
    foreach ($keys as $one) {
    	$col = '`'.$one.'`,';
    }
    $col = substr(0,strlen($col)-1);

    foreach ($values as $two) {
    	$val = '`'.$two.'`,';
    }
    $val = substr(0,strlen($val)-1);

    $sql = 'insert into $this->t_name ('. $col.')'.'values('. $val.')';
    $result = $this->query($sql);
    while($tmp=mysql_fetch_array($result,MYSQL_ASSOC)){
	$list[] = $tmp;
	}
	return $list;
}

public function delete($t_name,$where=''){
	$this->connect();
	$sql = 'delete from $this->t_name where $where';
	$result = $this->query($sql);
    while($tmp=mysql_fetch_array($result,MYSQL_ASSOC)){
	$list[] = $tmp;
	}
	return $list;
}

public function update($t_name,$update_array=array(),$where=''){
	$this->connect();
	$keys = array_keys($update_array);
    $values = array_values($update_array);
    foreach ($keys as $one) {
    	$col = '`'.$one.'`,';
    }
    $col = substr(0,strlen($col)-1);

    foreach ($values as $two) {
    	$val = '`'.$two.'`,';
    }
    $val = substr(0,strlen($val)-1);

    $sql = 'update $this->t_name set $col=$val where $where';
    $result = $this->query($sql);
    while($tmp=mysql_fetch_array($result,MYSQL_ASSOC)){
	$list[] = $tmp;
	}
	return $list;
}

public function getLastId(){
	

}














}



































































?>